package lyw0721_listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class ButtonListener implements ActionListener {
    public String name = "123456";
    public String answer = "123456";
    public JTextField userText;
    public JTextField userAnswer;

    public void actionPerformed(ActionEvent e) {
        System.out.println("点击按钮...");
        String username = userText.getText();
        String useranswer = userAnswer.getText();  //将从userAnswer文本框中获得的文本转化为useranswer文本


        if (name.equals(username) && answer.equals(useranswer)) {
            System.out.println("欢迎");
            newpage p=new newpage();
            p.show();
        } else {
            System.out.println("账号或密码错误");
        }

        System.out.println(username);
    }
}





